<?php
/**
 * Application level Controller
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       cake
 * @subpackage    cake.app
 */
	
	class AppController extends Controller {
		var $components = array('Auth', 'Session', 'RequestHandler');
		var $helpers = array('Html','Form','Session','Time');
		function beforeFilter() {
			$this->Auth->allowActions = array('login','logout');
			$this->Auth->authorize = 'controller';
			$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
			$user = $this->Session->read('Auth.User');
			$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index');			
			$this->Auth->loginError = 'Giriş Yapılamadı! Kullanıcı adı veya şifre hatalı!';
			$this->Auth->logoutRedirect = array('controller' => 'pages', 'action' => 'index');
			$this->Auth->actionPath = 'controllers/';
			$this->Auth->fields = array('username'=>'username','password'=>'password');
			$cart = $this->Session->read('cart');
			$this->loadModel('Book');
			$this->loadModel('Film');
			$this->loadModel('Music');
			$top_books = $this->Book->find('all',array('order'=>'Product.sold_count DESC','limit'=>'10'));
			$top_films = $this->Film->find('all',array('order'=>'Product.sold_count DESC','limit'=>'10'));
			$top_musics = $this->Music->find('all',array('order'=>'Product.sold_count DESC','limit'=>'10'));
			$this->set(compact('cart','user','top_books','top_films','top_musics'));
		}
	}
?>